"""
This exercise stub and the test suite contain several enumerated constants.

Enumerated constants can be done with a NAME assigned to an arbitrary,
but unique value. An integer is traditionally used because it’s memory
efficient.
It is a common practice to export both constants and functions that work with
those constants (ex. the constants in the os, subprocess and re modules).

You can learn more here: https://en.wikipedia.org/wiki/Enumerated_type
"""

# Possible sublist categories.
# Change the values as you see fit.
SUBLIST = 1
SUPERLIST = -1
EQUAL = 0
UNEQUAL = 2

## my try:
def sublist_old(list_one: list, list_two: list) -> int:
    if list_one == list_two:
        return EQUAL
    elif len(list_one) <= len(list_two):
        if len(list_one) == 0:
            return SUBLIST
        index_list = []
        for i in range(len(list_two)-len(list_one)+1):
            if list_two[i] == list_one[0]:
                print(f"Found subindex: {i}\n")
                index_list.append(i)
        if index_list == []:
            print("cannot find subindex!")
            return UNEQUAL
        for sub_index in index_list:
            if list_one == list_two[sub_index:sub_index+len(list_one)]:
                return SUBLIST
        return UNEQUAL
    else:
        rev_res = sublist(list_two, list_one)
        if rev_res == UNEQUAL:
            return UNEQUAL
        else:
            return -rev_res

# better:
def check_sub_sequences(list_one, list_two):
    n1 = len(list_one)
    n2 = len(list_two)
    return any(list_two[i:i+n1] == list_one for i in range(n2 - n1 + 1))
    
def sublist(list_one, list_two):
    if list_one == list_two:
        return EQUAL
    if check_sub_sequences(list_one, list_two):
        return SUBLIST
    if check_sub_sequences(list_two, list_one):
        return SUPERLIST
    return UNEQUAL


sublist([2,3],[2,4,2,3,4])
